package com.example.blogdemo

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.QuickViewHolder

class DefaultAdapter :BaseQuickAdapter<ClickItem,QuickViewHolder>(){
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: ClickItem?) {
        holder.setText(android.R.id.text1,item?.name)
    }
    init {
        setOnItemClickListener{_,_,position->
            getItem(position)?.click?.invoke()
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(android.R.layout.simple_list_item_1,parent)
    }
}

